/*
 * @Author: duanguang
 * @Date: 2019-11-07 09:31:57
 * @LastEditTime: 2021-10-27 22:44:06
 * @LastEditors: duanguang
 * @Description: 
 * @FilePath: /legions-server/app/controller/monitor.ts
 * 「扫去窗上的尘埃，才可以看到窗外的美景。」
 */
import CommonController from '../abstract/controller/common';
import { IQueryMonitorErrorListParams } from '../service/monitorError';
import { IQueryListCommonParams } from '../abstract/interface/common';

export default class MonitorController extends CommonController {
  /**
   * 查询错误信息列表
   */
  public async queryMonitorErrorList() {
    // @ts-ignore
    const query: IQueryMonitorErrorListParams & Partial<IQueryListCommonParams<string>> = this.ctx.query;
    const { page = 1, pageSize = 2, ...resQuery } = query;
    const pageOptions = {
      page: Number(page),
      pageSize: Number(pageSize),
    };
    const queryResult = await this.ctx.service.monitorError.queryMonitorErrorList(
      resQuery,
      pageOptions,
    );
    this.success(queryResult);
  }

  public async queryMonitorLogList() {
    // @ts-ignore
    const query: IQueryMonitorErrorListParams & Partial<IQueryListCommonParams<string>> = this.ctx.query;
    const { page = 1, pageSize = 10, ...resQuery } = query;
    const pageOptions = {
      page: Number(page),
      pageSize: Number(pageSize),
    };
    const queryResult = await this.ctx.service.monitorError.queryMonitorLogList(
      resQuery,
      pageOptions,
    );
    this.success(queryResult);
  }
}
